Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong transaction names in Django 4.0+ #1571

Merged
merged 4 commits into from
Jun 13, 2022
Merged

Fix wrong transaction names in Django 4.0+ #1571

merged 4 commits into from
Jun 13, 2022

Conversation

dhalenok
Copy link
Contributor

@dhalenok dhalenok commented Jun 9, 2022

What does this pull request do?

  • Tweaks get_name_from_func to use view_class attribute when resolving view name.

Related issues

closes #1570

@github-actions github-actions bot added agent-python community Issues opened by the community triage Issues awaiting triage labels Jun 9, 2022
@apmmachine
Copy link
Contributor

apmmachine commented Jun 9, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-06-13T14:39:28.129+0000

  • Duration: 35 min 14 sec

Test stats 🧪

Test Results
Failed 0
Passed 4905
Skipped 3455
Total 8360

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /test linters : Run the Python linters only.

  • /test full : Run the full matrix of tests.

  • /test benchmark : Run the APM Agent Python benchmarks tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@apmmachine
Copy link
Contributor

apmmachine commented Jun 9, 2022

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (68/68) 💚
Files 100.0% (227/227) 💚
Classes 100.0% (227/227) 💚
Lines 89.58% (17176/19174) 👍 0.006
Conditionals 76.655% (3126/4078) 👍 0.023

@beniwohli
Copy link
Contributor

@dhalenok awesome, thanks for opening the issue and this PR! The fix looks good. I was wondering why this wasn't caught by our tests, and it turns out we don't have any class based views in out test app. If you like, you could add one, and then test that we get the correct name by copying and modifying this test:

def test_transaction_metrics(django_elasticapm_client, client):
with override_settings(
**middleware_setting(django.VERSION, ["elasticapm.contrib.django.middleware.TracingMiddleware"])
):
assert len(django_elasticapm_client.events[TRANSACTION]) == 0
client.get(reverse("elasticapm-no-error"))
assert len(django_elasticapm_client.events[TRANSACTION]) == 1
transactions = django_elasticapm_client.events[TRANSACTION]
assert len(transactions) == 1
transaction = transactions[0]
assert transaction["duration"] > 0
assert transaction["result"] == "HTTP 2xx"
assert transaction["name"] == "GET tests.contrib.django.testapp.views.no_error"
assert transaction["outcome"] == "success"

Copy link
Contributor

@beniwohli beniwohli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix and test, thanks!

@beniwohli beniwohli merged commit fbfeabb into elastic:main Jun 13, 2022
@dhalenok dhalenok deleted the django4-transaction-name branch June 15, 2022 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-python community Issues opened by the community triage Issues awaiting triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong transaction name in Django 4.0+
3 participants